home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 50
/
Volume 50 - JOGO DISK .iso
/
Games
/
moonstonemadness.swf
/
scripts
/
__Packages
/
MiniGameManager.as
< prev
next >
Wrap
Text File
|
2007-09-27
|
8KB
|
247 lines
class MiniGameManager extends Library.DispatcherBase
{
static var TAK_FLY_START_X = 300;
static var TAK_FLY_START_Y = -50;
static var TAK_FOLLOW_Y = -150;
static var REMOVE_DEPTH = 1000000;
function MiniGameManager(__mcRef)
{
super();
this.mcRef = __mcRef;
MiniGameManager.oCtrl = this;
this.mcRef._y = Game.STAGE_HEIGHT;
this.aMoonStones = new Array();
this.aMiniStones = new Array();
this.nPosition = 0;
this.bScrollEnded = false;
this.bCalledEnd = false;
Main.__get__Instance().doAddListener(this);
this.doBuildLevel();
this.doStartWindFast();
}
static function get Instance()
{
return MiniGameManager.oCtrl;
}
function doSoundEvent(__nEvent, __oSound)
{
if(__nEvent === Library.Sound.SoundManager.EVENT_SOUND_COMPLETE)
{
if(__oSound == this.oWindSlow)
{
delete this.oWindSlow;
}
else if(__oSound == this.oWindNormal)
{
delete this.oWindNormal;
}
else if(__oSound == this.oWindFast)
{
delete this.oWindFast;
}
}
}
function doStopWinds()
{
if(this.oWindSlow != undefined)
{
this.oWindSlow.doFadeTo(0);
}
if(this.oWindNormal != undefined)
{
this.oWindNormal.doFadeTo(0);
}
if(this.oWindFast != undefined)
{
this.oWindFast.doFadeTo(0);
}
}
function doStartWindSlow()
{
if(this.oWindSlow == undefined)
{
Library.Sound.SoundManager.isSoundPlaying("Wind_Slow.wav").oSound.doStop();
this.oWindSlow = Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Wind_Slow.wav",0,999);
this.oWindSlow.doAddListener(this);
this.oWindSlow.setFadeRate(3);
}
this.oWindSlow.doFadeTo(100);
if(this.oWindNormal != undefined)
{
this.oWindNormal.doFadeTo(0);
}
if(this.oWindFast != undefined)
{
this.oWindFast.doFadeTo(0);
}
}
function doStartWindNormal()
{
if(this.oWindNormal == undefined)
{
Library.Sound.SoundManager.isSoundPlaying("Wind_Normal.wav").oSound.doStop();
this.oWindNormal = Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Wind_Normal.wav",0,999);
this.oWindNormal.doAddListener(this);
this.oWindNormal.setFadeRate(3);
}
this.oWindNormal.doFadeTo(100);
if(this.oWindSlow != undefined)
{
this.oWindSlow.doFadeTo(0);
}
if(this.oWindFast != undefined)
{
this.oWindFast.doFadeTo(0);
}
}
function doStartWindFast()
{
if(this.oWindFast == undefined)
{
Library.Sound.SoundManager.isSoundPlaying("Wind_Fast.wav").oSound.doStop();
this.oWindFast = Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Wind_Fast.wav",100,999);
this.oWindFast.doAddListener(this);
this.oWindFast.setFadeRate(3);
}
this.oWindFast.doFadeTo(100);
if(this.oWindNormal != undefined)
{
this.oWindNormal.doFadeTo(0);
}
if(this.oWindSlow != undefined)
{
this.oWindSlow.doFadeTo(0);
}
}
function doMinigameEnd()
{
if(!this.bCalledEnd)
{
this.bCalledEnd = true;
this.doStopWinds();
Game.__get__Instance().doMinigameEnd();
}
}
function doAddMiniStone(__mcObject)
{
var _loc2_ = new MiniStoneSky(__mcObject);
this.aMiniStones.push(_loc2_);
}
function doAddMoonStone(__mcObject)
{
var _loc2_ = new MoonStoneSky(__mcObject);
this.aMoonStones.push(_loc2_);
}
function doEnterFrame()
{
super.doEnterFrame();
if(!this.bPaused)
{
this.doScroll();
this.doCheckMoonstones();
this.doCheckMinistones();
}
}
function doDestroy()
{
super.doDestroy();
this.oWindFast.doStop();
this.oWindSlow.doStop();
this.oWindNormal.doStop();
delete this.oWindFast;
delete this.oWindSlow;
delete this.oWindNormal;
this.oTak.doDestroy();
delete this.oTak;
delete MiniGameManager.oCtrl;
Main.__get__Instance().doRemoveListener(this);
this.mcBg1.removeMovieClip();
this.mcBg2.removeMovieClip();
this.mcGame.removeMovieClip();
this.mcFront.removeMovieClip();
}
function doCheckMoonstones()
{
for(var _loc3_ in this.aMoonStones)
{
var _loc2_ = Library.Utils.MoreMath.getDistance(this.aMoonStones[_loc3_].Ref._x + this.aMoonStones[_loc3_].Ref._parent._x,this.aMoonStones[_loc3_].Ref._y + this.aMoonStones[_loc3_].Ref._parent._y,this.oTak.__get__Ref()._x,this.oTak.__get__Ref()._y);
if(_loc2_ < 75)
{
this.aMoonStones[_loc3_].onCatched();
Game.__get__Instance().onCatchMoonstone();
this.aMoonStones.splice(Number(_loc3_),1);
}
}
}
function doCheckMinistones()
{
for(var _loc3_ in this.aMiniStones)
{
var _loc2_ = Library.Utils.MoreMath.getDistance(this.aMiniStones[_loc3_].Ref._x + this.aMiniStones[_loc3_].Ref._parent._x,this.aMiniStones[_loc3_].Ref._y + this.aMiniStones[_loc3_].Ref._parent._y,this.oTak.__get__Ref()._x,this.oTak.__get__Ref()._y);
if(_loc2_ < 75)
{
this.aMiniStones[_loc3_].onCatched();
Game.__get__Instance().onCatchMiniStone();
this.aMiniStones.splice(Number(_loc3_),1);
}
}
}
function doScroll()
{
if(!this.bScrollEnded)
{
var _loc2_ = this.nPosition;
this.nTargetPosition = - (this.oTak.__get__Ref()._y - this.oTak.__get__FollowY());
if(this.nTargetPosition < 0)
{
this.nTargetPosition = 0;
this.nPosition = 0;
this.bScrollEnded = true;
}
else
{
this.nPosition += (this.nTargetPosition - this.nPosition) / 2;
}
this.mcBg1._y = this.nPosition * 0.2;
this.mcBg2._y = this.nPosition * 0.5;
this.mcGame._y = this.nPosition;
this.mcFront._y = this.nPosition * 1.1;
}
}
function doBuildLevel()
{
this.mcBg1 = this.mcRef.createEmptyMovieClip("mcBg1",1);
var _loc2_ = this.mcBg1.attachMovie("Panel_SkyBg","mcBg1_1",1);
_loc2_._y = - this.mcBg1._height;
this.mcBg2 = this.mcRef.createEmptyMovieClip("mcBg2",2);
var _loc3_ = 1;
while(_loc3_ <= 5)
{
_loc2_ = this.mcBg2.attachMovie("Panel_SkyBg2","mcBg2_" + _loc3_,_loc3_);
_loc2_._y = - _loc2_._height * _loc3_;
_loc3_ = _loc3_ + 1;
}
this.mcGame = this.mcRef.createEmptyMovieClip("mcGame",3);
_loc3_ = 1;
while(_loc3_ <= 4)
{
var _loc4_ = "Panel_SkyGame" + Library.Utils.MoreMath.getRandomRange(1,3);
_loc2_ = this.mcGame.attachMovie(_loc4_,"mcGame_" + _loc3_,_loc3_);
_loc2_._y = - _loc2_._height * _loc3_;
_loc3_ = _loc3_ + 1;
}
this.mcFront = this.mcRef.createEmptyMovieClip("mcFront",4);
_loc3_ = 1;
while(_loc3_ <= 14)
{
_loc2_ = this.mcBg2.attachMovie("Panel_SkyFront","mcFront_" + _loc3_,_loc3_);
_loc2_._y = - _loc2_._height * (_loc3_ * 0.99);
_loc3_ = _loc3_ + 1;
}
var _loc5_ = this.mcGame.attachMovie("Dynamic_TakFlying","mcTak",500);
_loc5_._x = MiniGameManager.TAK_FLY_START_X;
_loc5_._y = MiniGameManager.TAK_FLY_START_Y;
this.oTak = new TakFlying(_loc5_);
}
}